{extend name="layout" /}

{block name="content"}
<style>
	.layui-form-item .layui-form-label{
		width:140px;
	}
	.layui-input-block{
		margin-left:140px;
	}
</style>
<div class="layui-tab layui-tab-brief">
	<ul class="layui-tab-title">
	    <li><a href="{:url('index')}">{$pathCurrent['name']}</a></li>
	    <li class="layui-this">{empty name="info"}添加{else /}编辑{/empty}分配记录</li>
  	</ul>
</div>
<div class="layui-card-body">
	<form class="layui-form" data-model="form-submit">
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		  	<legend>基本设置</legend>
		</fieldset>
		<div class="layui-form-item">
			<label class="layui-form-label">产品选择</label>
			<div class="layui-input-block">
				<div class="layui-input-inline">
					<select name="goods_id" lay-verify="required" lay-search="">
						<option value="">直接选择或搜索选择</option>
						{foreach name="goods" item="item"}
						<option value="{$item.id}" {if condition="$item['id'] eq $info['goods_id']['value']"} selected {/if}>{$item.title}</option>
						{/foreach}
					</select>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">业务员选择</label>
			<div class="layui-input-block">
				<div class="layui-input-inline">
					<select name="customer_id" lay-verify="required" lay-search="">
						<option value="">直接选择或搜索选择</option>
						{foreach name="customer" item="item"}
						<option value="{$item.id}" {if condition="$item['id'] eq $info['customer_id']['value']"} selected {/if}>{$item.customer_name}</option>
						{/foreach}
					</select>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">起始二维码编号</label>
			<div class="layui-input-block">
				<input type="number" class="layui-input startNum"  name="start_num" value="{$info['start_num']}">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">结束二维码编号</label>
			<div class="layui-input-block">
				<input type="number" class="layui-input endNum" name="end_num" value="{$info['end_num']}" datatype="*">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">配送数量</label>
			<div class="layui-input-block">
				<input type="number" class="layui-input countNum" readonly style="color:gray;background-color:#f1f1f1;" name="count_num" value="{$info['count_num']|default=0}" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">备注说明</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" name="remark" value="{$info['remark']}">
			</div>
		</div>
		<!--<div class="layui-form-item">-->
	    	<!--<label class="layui-form-label">状态</label>-->
	    	<!--<div class="layui-input-block">-->
	    		<!--{php}$state = isset($info['status']) ? $info['status'] : '1';{/php}-->
	      		<!--<input type="radio" name="status" value="1" title="启用" {if $state eq 1} checked="" {/if}>-->
	      		<!--<input type="radio" name="status" value="2" title="冻结" {if $state eq 2} checked="" {/if}>-->
	    	<!--</div>-->
	  	<!--</div>-->
		<div class="layui-form-item">
	    	<div class="layui-input-block">
	    		<input type="hidden" name="id" value="{$info['id']}">
	      		<button class="layui-btn layui-btn-normal">保存</button>
	      		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	    	</div>
	  	</div>
	</form>
</div>
{/block}
{block name="js"}
<script type="text/javascript" src="/static/lib/assets/data.js"></script>
<script type="text/javascript">
    var mixin = {};
    layui.use('form',function(){
        var form = layui.form
       
    });





    function countNumGet(){
        let startNum = $('.startNum').val();
        let endNum   = $('.endNum').val();
        console.log(startNum);
        console.log(endNum);
        if( startNum == null || startNum === '' || endNum == null || endNum === '' ) return false;

        $('.countNum').val(endNum - startNum + 1);


	};


    $('.startNum').on('keyup',function(){
        countNumGet();
    });

    $('.endNum').on('keyup',function(){
        countNumGet();
    });

</script>
{/block}